// Auto create in 2017-06-21 00:04:56
/**
 * @author Jianbo
 * 合并模块
 */
"use strict"

var util = {};
util.exports = {};

/**
 * [addModule 添加模块]
 * @param name   [模块名]
 * @param module [模块对象]
 */
util.addModule = function (name, module) {
	util.exports[name] = module;
};

/**
 * 通用工具库
 * @author Jianbo
 * */
(function(){
	"use strict";
	
	var commonUtil = {};

	commonUtil.rand = function(min, max) {
        return Math.floor(Math.random() * (max - min) + min);
    };

	// 添加模块
	if (typeof util != "undefined") {
		util.addModule("commonUtil", commonUtil);
	} else {
		module.exports = commonUtil;
	}

	if(typeof window != "undefined") {
		window.CommonUtil = commonUtil; // window
	}
	
}());
// end ArrayUtil

/**
 * 数组工具库
 * @author Jianbo
 * */
(function(){
	"use strict";
	
	var arrayUtil = {};

	/**
	 * 排列对象数组
	 */
	arrayUtil.sort = function(list, key) {

	};
	
	/**
	 * 分割数组
	 * split Array
	 */
	arrayUtil.split = function(data, size) {
		var result = [];
		var len = data.length;
		for(var i = 0; i < len; i += size){
			result.push(data.slice(i, i + size));
		}
		return result;
	};

	/**
	 * 克隆数组
	 */
	arrayUtil.clone = function(arr) {
		var clone = new Array();
		for (var i = 0; i < arr.length; i++) {
			clone.push(arr[i]);
		}
		return clone;
	};

	/**
	 * 合并数组
	 * concatArray
	 */
	arrayUtil.concat = function(list1, list2) {
		return list1.concat(list2);
	}
	
	/**
	 * 如果在数组里存在，则返回true
	 * */
	arrayUtil.inArray = function(object, arr){
		var flag = false;
		for (var i = 0; i < arr.length; i++) {
			var v = arr[i];
			if (v === object) {
				flag = true;
			}
		}
		return flag;
	}

	/**
	 * 对象数组获取对象
	 */
	arrayUtil.getObject = function(array, key, value) {
		for (var i = 0; i < array.length; i++) {
			var element = array[i];
			if(element[key] == value) {
				return element;
			}
		};
		return false;
	}

	// 添加模块
	if (typeof util != "undefined") {
		util.addModule("arrayUtil", arrayUtil);
	} else {
		module.exports = arrayUtil;
	}

	if(typeof window != "undefined") {
		window.ArrayUtil = arrayUtil; // window
	}
	
}());
// end ArrayUtil

/**
 * @see https://github.com/pvorb/clone
 */
var clone = (function() {
    'use strict';

    function _instanceof(obj, type) {
        return type != null && obj instanceof type;
    }

    var nativeMap;
    try {
        nativeMap = Map;
    } catch (_) {
        // maybe a reference error because no `Map`. Give it a dummy value that no
        // value will ever be an instanceof.
        nativeMap = function() {};
    }

    var nativeSet;
    try {
        nativeSet = Set;
    } catch (_) {
        nativeSet = function() {};
    }

    var nativePromise;
    try {
        nativePromise = Promise;
    } catch (_) {
        nativePromise = function() {};
    }

    /**
     * Clones (copies) an Object using deep copying.
     *
     * This function supports circular references by default, but if you are certain
     * there are no circular references in your object, you can save some CPU time
     * by calling clone(obj, false).
     *
     * Caution: if `circular` is false and `parent` contains circular references,
     * your program may enter an infinite loop and crash.
     *
     * @param `parent` - the object to be cloned
     * @param `circular` - set to true if the object to be cloned may contain
     *    circular references. (optional - true by default)
     * @param `depth` - set to a number if the object is only to be cloned to
     *    a particular depth. (optional - defaults to Infinity)
     * @param `prototype` - sets the prototype to be used when cloning an object.
     *    (optional - defaults to parent prototype).
     * @param `includeNonEnumerable` - set to true if the non-enumerable properties
     *    should be cloned as well. Non-enumerable properties on the prototype
     *    chain will be ignored. (optional - false by default)
     */
    function clone(parent, circular, depth, prototype, includeNonEnumerable) {
        if (typeof circular === 'object') {
            depth = circular.depth;
            prototype = circular.prototype;
            includeNonEnumerable = circular.includeNonEnumerable;
            circular = circular.circular;
        }
        // maintain two arrays for circular references, where corresponding parents
        // and children have the same index
        var allParents = [];
        var allChildren = [];

        var useBuffer = typeof Buffer != 'undefined';

        if (typeof circular == 'undefined')
            circular = true;

        if (typeof depth == 'undefined')
            depth = Infinity;

        // recurse this function so we don't reset allParents and allChildren
        function _clone(parent, depth) {
            // cloning null always returns null
            if (parent === null)
                return null;

            if (depth === 0)
                return parent;

            var child;
            var proto;
            if (typeof parent != 'object') {
                return parent;
            }

            if (_instanceof(parent, nativeMap)) {
                child = new nativeMap();
            } else if (_instanceof(parent, nativeSet)) {
                child = new nativeSet();
            } else if (_instanceof(parent, nativePromise)) {
                child = new nativePromise(function(resolve, reject) {
                    parent.then(function(value) {
                        resolve(_clone(value, depth - 1));
                    }, function(err) {
                        reject(_clone(err, depth - 1));
                    });
                });
            } else if (clone.__isArray(parent)) {
                child = [];
            } else if (clone.__isRegExp(parent)) {
                child = new RegExp(parent.source, __getRegExpFlags(parent));
                if (parent.lastIndex) child.lastIndex = parent.lastIndex;
            } else if (clone.__isDate(parent)) {
                child = new Date(parent.getTime());
            } else if (useBuffer && Buffer.isBuffer(parent)) {
                child = new Buffer(parent.length);
                parent.copy(child);
                return child;
            } else if (_instanceof(parent, Error)) {
                child = Object.create(parent);
            } else {
                if (typeof prototype == 'undefined') {
                    proto = Object.getPrototypeOf(parent);
                    child = Object.create(proto);
                } else {
                    child = Object.create(prototype);
                    proto = prototype;
                }
            }

            if (circular) {
                var index = allParents.indexOf(parent);

                if (index != -1) {
                    return allChildren[index];
                }
                allParents.push(parent);
                allChildren.push(child);
            }

            if (_instanceof(parent, nativeMap)) {
                parent.forEach(function(value, key) {
                    var keyChild = _clone(key, depth - 1);
                    var valueChild = _clone(value, depth - 1);
                    child.set(keyChild, valueChild);
                });
            }
            if (_instanceof(parent, nativeSet)) {
                parent.forEach(function(value) {
                    var entryChild = _clone(value, depth - 1);
                    child.add(entryChild);
                });
            }

            for (var i in parent) {
                var attrs;
                if (proto) {
                    attrs = Object.getOwnPropertyDescriptor(proto, i);
                }

                if (attrs && attrs.set == null) {
                    continue;
                }
                child[i] = _clone(parent[i], depth - 1);
            }

            if (Object.getOwnPropertySymbols) {
                var symbols = Object.getOwnPropertySymbols(parent);
                for (var i = 0; i < symbols.length; i++) {
                    // Don't need to worry about cloning a symbol because it is a primitive,
                    // like a number or string.
                    var symbol = symbols[i];
                    var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
                    if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
                        continue;
                    }
                    child[symbol] = _clone(parent[symbol], depth - 1);
                    if (!descriptor.enumerable) {
                        Object.defineProperty(child, symbol, {
                            enumerable: false
                        });
                    }
                }
            }

            if (includeNonEnumerable) {
                var allPropertyNames = Object.getOwnPropertyNames(parent);
                for (var i = 0; i < allPropertyNames.length; i++) {
                    var propertyName = allPropertyNames[i];
                    var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
                    if (descriptor && descriptor.enumerable) {
                        continue;
                    }
                    child[propertyName] = _clone(parent[propertyName], depth - 1);
                    Object.defineProperty(child, propertyName, {
                        enumerable: false
                    });
                }
            }

            return child;
        }

        return _clone(parent, depth);
    }

    /**
     * Simple flat clone using prototype, accepts only objects, usefull for property
     * override on FLAT configuration object (no nested props).
     *
     * USE WITH CAUTION! This may not behave as you wish if you do not know how this
     * works.
     */
    clone.clonePrototype = function clonePrototype(parent) {
        if (parent === null)
            return null;

        var c = function() {};
        c.prototype = parent;
        return new c();
    };

    // private utility functions

    function __objToStr(o) {
        return Object.prototype.toString.call(o);
    }
    clone.__objToStr = __objToStr;

    function __isDate(o) {
        return typeof o === 'object' && __objToStr(o) === '[object Date]';
    }
    clone.__isDate = __isDate;

    function __isArray(o) {
        return typeof o === 'object' && __objToStr(o) === '[object Array]';
    }
    clone.__isArray = __isArray;

    function __isRegExp(o) {
        return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
    }
    clone.__isRegExp = __isRegExp;

    function __getRegExpFlags(re) {
        var flags = '';
        if (re.global) flags += 'g';
        if (re.ignoreCase) flags += 'i';
        if (re.multiline) flags += 'm';
        return flags;
    }
    clone.__getRegExpFlags = __getRegExpFlags;

    return clone;
})();

// if (typeof module === 'object' && module.exports) {
//     module.exports = clone;
// }

// 添加模块
if (typeof util != "undefined") {
    util.addModule("clone", clone);
}

if(typeof window != "undefined") {
    window.clone = clone; // window
}

/**
 * 日期扩展
 */
(function () {
    
    "use stricts";
    
    var msOfSecond = 1000;
    var msOfHour = 3600 * msOfSecond;
    var msOfDay = 24 * msOfHour;
    var _msOfYear = function() {
        if((year % 4 == 0) && (year % 100 != 0 || year % 400 == 0)) {
            return 366 * msOfDay;
        } else {
            return 365 * msOfDay;
        }
    };
    
    /**
     * [parse 根据字符串返回Date 类型]
     * yyyy--MM--dd HH:mm:ss
     * 2012--01--12 14:14:59
     */
    Date.parse = function (fmt, str) {
        var map = {
            year: "y",
            day: "d",
            month: "M",
            hour: "H",
            minute: "m",
            second: "s"
        };

        // 获取值
        var getMapValure = function (type) {
            var start = fmt.indexOf(type);
            var end = fmt.lastIndexOf(type);
            return str.substring(start, end + 1);
        };

        var year = getMapValure(map.year);
        var month = getMapValure(map.month);
        var day = getMapValure(map.day);
        var hour = getMapValure(map.hour);
        var minute = getMapValure(map.minute);
        var second = getMapValure(map.second);

        return new Date(year, month - 1, day, hour, minute, second);
    };

    // 根据月份获取日期
    Date.getByMonth = function(month) {
        var date = new Date();
        date.setMonth(month);
        return date;
    };

    // 获取零点的Date对象
    Date.prototype.zeroPoint = function() {
        var date = new Date(this.getTime());
        date.setHours(0);
        date.setMinutes(0);
        date.setSeconds(0);
        date.setMilliseconds(0);
        return date;
    };

    // 获取月份第一天零点的Date对象
    Date.prototype.monthFirstDay = function() {
        var date = new Date(this.getTime());
        date.setDate(1);
        date = date.zeroPoint();
        return date;
    };

    /**
     * 相差天数 this - 参数 
     * 多出来的部分算一天
     * @param {type} endDate
     * @returns {Number|Date@call;getTime}
     */
    Date.prototype.diffDay = function (endDate) {
        var diff = endDate.getTime() - this.getTime();
        var diffDay = (diff - (diff % msOfDay)) / msOfDay;
        if(diff % msOfDay == 0) {
            return diffDay;
        } else {
            return diffDay + 1;
        }
    };
    
    /**
     * 相差小时 this - 参数
     * 多出来的部分算一个小时
     * @param {type} endDate
     * @returns {Date@call;getTime|Number}
     */
    Date.prototype.diffHour = function (endDate) {
        var diff = endDate.getTime() - this.getTime();
        var diffHour = (diff - (diff % msOfHour)) / msOfHour;
        if(diff % msOfHour == 0) {
            return diffHour;
        } else {
            return diffHour + 1;
        }
    };
    
    /**
     * 获得当月的天数
     */
    Date.prototype.dayCount = function() {
        var year = this.getFullYear();
        var month = this.getMonth() + 1;
        return (new Date(year, month, 0)).getDate();
    };
    
    /**
     * 上个月当天
     */
    Date.prototype.lastMonthToday = function() {
        // 上个月天数
        // var lastMonthDayCount = (new Date(this.getTime() - this.dayCount * msOfDay)).dayCount();
        // return new Date(this.getTime() - lastMonthDayCount * msOfDay);
        var date = new Date(this.getTime());
        var month = this.getMonth() - 1;
        var year = this.getFullYear();
        if(this.getMonth() == 0) {
            month = 11; 
            year --;
        }
        date.setMonth(month);
        date.setFullYear(year);
        return date;
    };

    /**
     * 用法 date.format("yy-MM-dd HH:mm:ss");
     * @param {type} fmt
     * @returns {unresolved}
     */
    Date.prototype.format = function (fmt) {
        // 默认值
        if (fmt == null) {
            fmt = "yyyy-MM-dd HH:mm:ss";
        }
        var o = {
            "M+": this.getMonth() + 1, // 月份
            "d+": this.getDate(), // 日
            "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, // 小时
            "H+": this.getHours(), // 小时
            "m+": this.getMinutes(), // 分
            "s+": this.getSeconds(), // 秒
            "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
            "S": this.getMilliseconds()
                    // 毫秒
        };
        var week = {
            "0": "/u65e5",
            "1": "/u4e00",
            "2": "/u4e8c",
            "3": "/u4e09",
            "4": "/u56db",
            "5": "/u4e94",
            "6": "/u516d"
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
                    .substr(4 - RegExp.$1.length));
        }
        if (/(E+)/.test(fmt)) {
            fmt = fmt
                    .replace(
                            RegExp.$1,
                            ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f"
                                    : "/u5468")
                                    : "")
                            + week[this.getDay() + ""]);
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
                        : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    };

}());
/**
 * [日期工具类]
 */
(function() {
	"use strict";

	var dateUtil = function() {

		var self = {};

		return self;
	}();

	// unfinish
	// window.DateUtil = dateUtil;

}());
/**
 * name : Log.js
 * author : Jianbo
 * description : 自定义打印变量
 * create : 2016-08-03
 */
(function(){
	// 严格模式
	"use strict";

	if(typeof console == "undefined") {
		window.console = {};
		window.console.log = function(){};
		widnow.console.debug = function(){};
	}

	// 将log定义成函数对象
	var log = function() {
		console.log.apply(console, arguments);
	};

	log.error = function(str) {
		log("Error: "+str);
	};

	// 换行
	log.ln = function() {
		console.log();
	};

	// end
	log.end = function() {
		console.log("|---------- end --------------");
	};

	// 结束并换行
	log.endln = function() {
		log.end();
		log.ln();
	};

	// 打印变量
	log.dump = function(Obj) {
		function printStart(title) {
			var str = "|---------- "+title+" ";
			var len = 17 - title.length;
			for (var i = 0; i < len; i++) {
				str = str + "-";
			}
			console.log(str);
		}

		log.end();

		// 是否为数组
		if(Array.isArray(Obj)) {
			printStart("Array");
			for (var i = 0; i < Obj.length; i++) {
				console.log("|", i, ":", Obj[i]);
			};
			log.end();
			return;
		}

		log.ln();
		printStart(typeof Obj);
		// 打印对象
		if(typeof Obj == "object") {
			for(var key in Obj) {
				if (typeof Obj[key] == "function") {
					console.log("| ", key, "->", "function(){...}");
				} else {
					console.log("| ", key, "->", Obj[key]);
				}
			}

		// 打印函数
		} else if(typeof Obj == "function") {
			var object = new Obj();
			var returnValue = Obj.call(object);
			for(var key in object) {
				if (typeof object[key] == "function") {
					console.log("| ", key, "->", "function(){...}");
				} else {
					console.log("| ", key, "->", object[key]);
				}
			}
			console.log("| ", "[Return]", ":", returnValue);

		// 打印其他类型
		} else {
			console.log("| ", Obj);
		}
		log.end();
	};

	log.info = function(){
		var t = {};
		//删除所有HTML标签
		t.removeHtmlTab = function(tab) {
			return tab.replace(/<[^<>]+?>/g,'');
		}
		//普通字符转换成转意符
		t.html2Escape = function(sHtml) {
		 	return sHtml.replace(/[<>&"]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];});
		}
		//转意符换成普通字符
		t.escape2Html = function(str) {
		 	var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
		 	return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
		}
		// &nbsp;转成空格
		t.nbsp2Space = function(str) {
		 	var arrEntities = {'nbsp' : ' '};
		 	return str.replace(/&(nbsp);/ig, function(all, t){return arrEntities[t]})
		}
		//回车转为br标签
		t.return2Br = function(str) {
		 	return str.replace(/\r?\n/g,"<br />");
		}
		//回车转为\n
		t.return2Ln = function(str) {
			//str=str.replace(/\t/g, "\\t")
		 	return str.replace(/\r?\n/g,"\\n");
		}

		//去除开头结尾换行,并将连续3次以上换行转换成2次换行
		t.trimBr = function(str) {
			str=str.replace(/((\s|&nbsp;)*\r?\n){3,}/g,"\r\n\r\n");//限制最多2次换行
			str=str.replace(/^((\s|&nbsp;)*\r?\n)+/g,'');//清除开头换行
			str=str.replace(/((\s|&nbsp;)*\r?\n)+$/g,'');//清除结尾换行
			return str;
		}
		
		// 将多个连续空格合并成一个空格	
		t.mergeSpace = function(str) {
			str=str.replace(/(\s|&nbsp;)+/g,' ');
			return str;
		}
		
		return t;
	}();

	// 添加模块
	if (typeof util != "undefined") {
		util.addModule("log", log);
	}

	if(typeof window != "undefined") {
		window.log = log; // window
	}

}());

/**
 * Util : 工具类
 * userful : 字符串处理 数组处理 获取对象类型
 * version : 0.2
 */
(function() {
	"use strict";

	var objectUtil = {};

	/**
	 * [cloneObj 克隆对象]
	 */
	objectUtil.cloneObj = function(obj){
	    var str, newobj = obj.constructor === Array ? [] : {};
	    if(typeof obj !== 'object'){
	        return;
	    } else if(window.JSON){
	        str = JSON.stringify(obj), //系列化对象
	        newobj = JSON.parse(str); //还原
	    } else {
	        for(var i in obj){
	            newobj[i] = typeof obj[i] === 'object' ? 
	            cloneObj(obj[i]) : obj[i]; 
	        }
	    }
	    return newobj;
	};

	objectUtil.getType = function(object) {
		var type = typeof object;
		if (object == undefined) {
			if(typeof object == "object") {
				return "null";
			} else {
				return undefined;
			}
		}
		if (type == "string") {
			return "string";
		} else if (type == "function") {
			return "function";
		} else if (type == "boolean") {
			return "boolean";
		} else if (type == "number") {
			return "number";
		} else if (type == "object") {
			if(object instanceof Date) {
				return "date";
			} else if (object instanceof Array) {
				return "array";
			}
			return "object";
		} else {
			return "other";
		}
	};

	// 添加模块
	if (typeof util != "undefined") {
		util.addModule("objectUtil", objectUtil);
	}

	if(typeof window != "undefined") {
		window.ObjectUtil = objectUtil; // window
	}

}());

// String Extend 
(function() {

	//替换所有
	String.prototype.replaceAll = function(s1, s2){ 
		var reg = new RegExp(s1, "gm");
		return this.replace(reg, s2); 
	}
	/**
	 * 原型：字符串格式化
	 * @param args 格式化参数值
	 */
	String.prototype.format = function(args) {
	    var result = this;
	    if (arguments.length < 1) {
	        return result;
	    }

	    var data = arguments; // 如果模板参数是数组
	    if (arguments.length == 1 && typeof (args) == "object") {
	        // 如果模板参数是对象
	        data = args;
	    }
	    for ( var key in data) {
	        var value = data[key];
	        if (undefined != value) {
	            result = result.replaceAll("\\{" + key + "\\}", value);
	        }
	    }
	    return result;
	}
	
	//获取字符数组 
	String.prototype.toCharArray = function() {
	    return this.split("");
	}
	//获取N个相同的字符串 
	String.prototype.repeat = function(num) {
	    var tmpArr = [];
	    for ( var i = 0; i < num; i++)
	        tmpArr.push(this);
	    return tmpArr.join("");
	}
	//逆序 
	String.prototype.reverse = function() {
	    return this.split("").reverse().join("");
	}
	//测试是否是数字 
	String.prototype.isNumeric = function() {
	    var tmpFloat = parseFloat(this);
	    if (isNaN(tmpFloat))
	        return false;
	    var tmpLen = this.length - tmpFloat.toString().length;
	    return tmpFloat + "0".Repeat(tmpLen) == this;
	}
	//测试是否是整数 
	String.prototype.isInt = function() {
	    if (this == "NaN")
	        return false;
	    return this == parseInt(this).toString();
	}
	// 合并多个空白为一个空白 
	String.prototype.resetBlank = function() {
	    return this.replace(/\s+/g, " ");
	}
	// 除去左边空白 
	String.prototype.LTrim = function() {
	    return this.replace(/^\s+/g, "");
	}
	// 除去右边空白 
	String.prototype.RTrim = function() {
	    return this.replace(/\s+$/g, "");
	}
	// 除去两边空白 
	String.prototype.trim = function() {
	    return this.replace(/(^\s+)|(\s+$)/g, "");
	}
	// 保留数字 
	String.prototype.getNum = function() {
	    return this.replace(/[^d]/g, "");
	}
	// 保留字母 
	String.prototype.getEn = function() {
	    return this.replace(/[^A-Za-z]/g, "");
	}
	// 保留中文 
	String.prototype.getCn = function() {
	    return this.replace(/[^u4e00-u9fa5uf900-ufa2d]/g, "");
	}
	// 得到字节长度 
	String.prototype.getRealLength = function() {
	    return this.replace(/[^x00-xff]/g, "--").length;
	}
	// 从左截取指定长度的字串 
	String.prototype.left = function(n) {
	    return this.slice(0, n);
	}
	// 从右截取指定长度的字串 
	String.prototype.right = function(n) {
	    return this.slice(this.length - n);
	}
	// HTML编码 
	String.prototype.HTMLEncode = function() {
	    var re = this;
	    var q1 = [ /x26/g, /x3C/g, /x3E/g, /x20/g ];
	    var q2 = [ "&", "<", ">", " " ];
	    for ( var i = 0; i < q1.length; i++)
	        re = re.replace(q1[i], q2[i]);
	    return re;
	}
	// Unicode转化 
	String.prototype.ascW = function() {
	    var strText = "";
	    for ( var i = 0; i < this.length; i++)
	        strText += "&#" + this.charCodeAt(i) + ";";
	    return strText;
	}
	// 按行分割字符串数组
	String.prototype.getArrayByLine = function() {
	    return this.split(/\n/);
	}
	/**
	 * 截取第一个separator字符后面的所有字符
	 * */
	String.prototype.substringAfter =  function(separator){
	    var i = this.indexOf(separator);
	    if(i > -1){
	        return this.substring(i + separator.length, this.length);
	    }else{
	        return null;
	    }
	};
	/**
	 * 截取第一个separator字符前面的所有字符
	 * */
	String.prototype.substringBefore = function (separator){
	    var i = this.indexOf(separator);
	        if(i > -1){
	            return this.substring(0, i);
	        }else{
	            return null;
	    }
	}

	/**
	 * 按照substr截取字符串
	 * How do you do? 截取 do
	 * return ["How "," you do?"]
	 */
	String.prototype.splitByWord = function (substr){
	    var index = this.indexOf(substr); 
	    if (index == -1) {
	        return false;
	    }
	    var left = this.substring(0, index);
	    var right = this.substring(index + substr.length, this.length);
	    return {
	        left : left,
	        right : right
	    };
	}

}());
/**
 * StringBuilder [字符串创建类]
 */
(function(){
	function StringBuilder(){
		this.__string__ = new Array();
	}
	//////////////////////////////////////////////////////////////////////////////
	//功能说明： 定义StringBuiler的append方法
	//////////////////////////////////////////////////////////////////////////////
	StringBuilder.prototype.append = function(str){
		this.__string__.push(str);
	};
	//////////////////////////////////////////////////////////////////////////////
	//功能说明： 定义StringBuiler的toString方法
	//////////////////////////////////////////////////////////////////////////////
	StringBuilder.prototype.toString = function(){
		return this.__string__.join("");
	};

	// 添加模块
	if (typeof util != "undefined") {
		util.addModule("StringBuilder", StringBuilder);
	}

	if(typeof window != "undefined") {
		window.StringBuilder = StringBuilder; // window
	}
	
}());
/**
 * 字符串工具库
 * @author jianbo
 * */
(function(){
	"use strict";
	
	var stringUtil = {};
	
	/**
	 * 以某字符串开头
	 * */
	stringUtil.startWith = function(str, prefix){
		if(typeof str === "string" && str.length > 0 && prefix.length > 0){
			return str.substr(0, prefix.length) == prefix;
		}
		return false;
	}
	
	stringUtil.isBlank = function(str){
		return !stringUtil.isNotBlank(str);
	}

	stringUtil.isNotBlank = function(str){
		return typeof str === "string" && str != "";
	}
	
	/**
	 * 截取第一个separator字符后面的所有字符
	 * */
	stringUtil.substringAfter =  function(s, separator){
		var i = s.indexOf(separator);
		if(i > -1){
			return s.substring(i + separator.length, s.length);
		}else{
			return null;
		}
	};
	/**
	 * 截取第一个separator字符前面的所有字符
	 * */
	stringUtil.substringBefore = function (s, separator){
		var i = s.indexOf(separator);
			if(i > -1){
				return s.substring(0, i);
			}else{
				return null;
		}
	}
	//字符串的首字母大写
	stringUtil.toUpperCaseFirstChar = function (s) {
	    return s.substring(0, 1).toUpperCase() + s.substring(1, s.length);
	}
	//字符串的首字母小写
	stringUtil.toLowerCaseFirstChar = function (s) {
	    return s.substring(0, 1).toLowerCase() + s.substring(1, s.length);
	}
	/**
	 * 命名转换：下划线命名法转骆驼命名法
	 * UnderScoreCase2CamelCase
	 */
	stringUtil.U2CamelCase = function (naming) {
		var words = naming.split('_');
		var wordStr = "";
		for (var i = 0; i < words.length; i++) {
			var word = words[i];
			// 所有字母小写
			word = word.toLowerCase();
			// 首字母大写
			word = stringUtil.toUpperCaseFirstChar(word);
			if (i == 0) {
				// 第一个字母小写
				word = stringUtil.toLowerCaseFirstChar(word);
			}
			wordStr += word;
		}
		return wordStr;
	}
	
	/**
	 * 命名转换：下划线命名法转帕斯卡命名法
	 * UnderScoreCase2PascalCase
	 */
	stringUtil.U2PascalCase = function (naming) {
		var camelCaseWord = stringUtil.U2CamelCase(naming);
		return stringUtil.toUpperCaseFirstChar(camelCaseWord);
	}

	// 添加模块
	if (typeof util != "undefined") {
		util.addModule("stringUtil", stringUtil);
	}

	if(typeof window != "undefined") {
		window.StringUtil = stringUtil; // window
	}
	
})();
/**
 * TimeUtil 时间工具库
 * @author Jianbo
 * */
(function(){
	"use strict";

	var timeUtil = {};
	
	var data = {};
		
	timeUtil.getUnixTime = function() {
		return (new Date()).getTime();
	};
	
	timeUtil.startTime = function(tag) {
		if (typeof tag == "undefined") {
			data.start = timeUtil.getUnixTime();
		} else {
			data[tag] = timeUtil.getUnixTime();
		}
	};
	
	timeUtil.endTime = function(tag) {
		var now = timeUtil.getUnixTime();
		var useTime;
		if (typeof tag == "undefined") {
			useTime = now - data.start;
		} else {
			useTime = now - data[tag];
		}
		console.log("Use "+useTime+" ms");
	};

	// 添加模块
	if (typeof util != "undefined") {
		util.addModule("timeUtil", timeUtil);
	}

	if(typeof window != "undefined") {
		window.TimeUtil = timeUtil; 
	}

})();

/**
 * 验证工具库
 * @author jianbo
 * */
(function() {
	"use strict";

	var validateUtil = {};

	/**验证车牌号码*/
	validateUtil.isCarLicense = function(license) {
		var regExp = /[A-Z]{1}[A-Z_0-9]{4}[a-zA-Z_0-9_\u4e00-\u9fa5]$/;
		return regExp.test(license);
	}

	/**验证手机号码*/
	validateUtil.isMobilePhone = function(phoneNum) {
		var regExp = /^0?(13[0-9]|15[012356789]|18[02356789]|14[57])[0-9]{8}$/;
		return regExp.test(phoneNum);
	}

	/**验证身份证号码*/
	validateUtil.isIdCardNo = function(number) {

		// 身份证正则表达式(15位)
		//var isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/; 
		var isIDCard1 = /^[0-9]{15}$/;
		// 身份证正则表达式(18位)
		//var isIDCard2=/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/; 
		var isIDCard2 = /^[0-9]{17}[X_0-9]$/;

		// 验证身份证最后一位号码
		var checkLastChar = function(number) {
			var xishu = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
			var lastNumber = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
			var cardNostring = number.split("");
			var sum = 0;
			for (var i = 0; i < cardNostring.length - 1; i++) {
				sum += (cardNostring[i] - '0') * xishu[i];
			}
			return lastNumber[sum % 11] == cardNostring[17];
		}

		if (number.length == 15) {
			return isIDCard1.test(number);
		}
		if (number.length == 18) {
			return isIDCard2.test(number) && checkLastChar(number);
		}

		return true;
	}

	/** 校验是否只有数字或者字母 */
	validateUtil.hasOnlyCharOrNumber = function(value) {
		var regExp = /^[A-Za-z0-9]+$/;
		return regExp.test(value);
	}

	/** 校验email */
	validateUtil.isEmail = function(email) {
		var reg = /\w@\w*\.\w/;
		return reg.test(email);
	}

	// 添加模块
	if (typeof util != "undefined") {
		util.addModule("validateUtil", validateUtil);
	}

	if(typeof window != "undefined") {
		window.ValidateUtil = validateUtil; 
	}

})();
/**
 * xml工具库
 * @author jianbo
 * */
(function() {
    "use strict";

    var xmlUtil = {};

    xmlUtil.loadXMLString = function(txt){
        try //Internet Explorer
        {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = "false";
            xmlDoc.loadXML(txt);
            return (xmlDoc);
        } catch (e) {
            try //Firefox, Mozilla, Opera, etc.
            {
                parser = new DOMParser();
                xmlDoc = parser.parseFromString(txt, "text/xml");
                return (xmlDoc);
            } catch (e) {
                console.log(e.message) ;
            }
        }
        return (null);
    };

    xmlUtil.xmlToJson = function(xml) {
        // Create the return object
        var obj = {};
        if (xml.nodeType == 1) { // element
            // do attributes
            if (xml.attributes.length > 0) {
                obj["@attributes"] = {};
                for (var j = 0; j < xml.attributes.length; j++) {
                    var attribute = xml.attributes.item(j);
                    obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
                }
            }
        } else if (xml.nodeType == 3) { // text
            obj = xml.nodeValue;
        }
        // do children
        if (xml.hasChildNodes()) {
            for (var i = 0; i < xml.childNodes.length; i++) {
                var item = xml.childNodes.item(i);
                var nodeName = item.nodeName;
                if (typeof(obj[nodeName]) == "undefined") {
                    obj[nodeName] = xmlUtil.xmlToJson(item);
                } else {
                    if (typeof(obj[nodeName].length) == "undefined") {
                        var old = obj[nodeName];
                        obj[nodeName] = [];
                        obj[nodeName].push(old);
                    }
                    obj[nodeName].push(xmlUtil.xmlToJson(item));
                }
            }
        }
        return obj;
    };

    // 添加模块
    if (typeof util != "undefined") {
        util.addModule("xmlUtil", xmlUtil);
    }

    if (typeof window != "undefined") {
        window.XmlUtil = xmlUtil; // window
    }

})();


// 导出合并后的模块
if (typeof exports === 'object' && exports && typeof exports.nodeName !== 'string') {
	module.exports = util.exports; // CommonJS
} else if (typeof define === 'function' && define.amd) {
	define(['exports'], function(){
		return util.exports;
	}); // AMD
}